#include <iostream>
#include <string>

using namespace std;

void permute(string *chars, string permutation)
{
   if(permutation.size() == chars->size())
   {
      cout<<permutation<<endl;
      return;
   }
   for(int i = 0; i < permutation.size() + 1; i++)
   {
      //cout<<"debug: "<<permutation.substr(0,i) + (*chars)[permutation.size()] + permutation.substr(i)<<endl;
      permute(chars, permutation.substr(0,i)
                     + (*chars)[permutation.size()]
                     + permutation.substr(i));
   }
}

int main()
{
   string word;
   int first = 1;
   while(cin>>word)
   {
      if(first) first = 0;
      else cout<<endl;
      permute(&word, "");
   }
   return 0;
}
